﻿<cfsilent>
	<cfscript>
	
		propAdvice = getProperty("serviceFactory").getBean("studentPropertyAdvice");
		jsonAdvice = getProperty("serviceFactory").getBean("jsonAdvice");
		
		response = structNew();
		
		transaction {
			
			sql = "SELECT a.student_prop 
					FROM t_student_status a 
					WHERE a.stu_id = :stuId ";
			
			queryObj = new Query(datasource = application.dnsMaster);
			queryObj.addParam(name = "stuId", value = event.getArg("STUID"), cfsqltype = "cf_sql_varchar");
			rs_student = queryObj.execute(sql = sql).getResult();
		
			propAdvice.parseProperty( rs_student.student_prop );
			
			switch ( event.getArg('prop' )) {
				
				case "Debt":
					
					/* 是否拖欠学费 */
					if ( yesNoFormat(event.getArg('status')) ) {
						propAdvice.setDebt( true );
					}
					else {
						propAdvice.setDebt( false );
					}
					
					break;
				
				case "Poor":
					
					/* 是否享受贫困生绿色通道 */
					if ( yesNoFormat(event.getArg('status')) ) {
						propAdvice.setPoor( true );
					}
					else {
						propAdvice.setPoor( false );
					}
					
					break;
					
				
				
			}
			
			sql = "UPDATE t_student_status a 
					SET a.student_prop = :StudentProps  
					WHERE a.stu_id = :stuId ";
			
			queryObj = new Query(datasource = application.dnsMaster);
			queryObj.addParam(name = "stuId", value = event.getArg("STUID"), cfsqltype = "cf_sql_varchar");
			queryObj.addParam(name = "StudentProps", value = propAdvice.stringProperty(), cfsqltype = "cf_sql_varchar");
			queryObj.execute(sql = sql);
			
			
			structInsert(response, "Poor", propAdvice.getPoor());
			structInsert(response, "Debt", propAdvice.getDebt());
			
		}
	
	</cfscript>
</cfsilent><cfoutput>#jsonAdvice.encode(data:response, stringNumbers:true)#</cfoutput>